package com.canlihao.ui.mvp.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.canlihao.ui.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by QYG_XXY on 0007 2017/12/7.
 */
public class DialogLoading extends Dialog {
    private static final String TAG = "DialogLoading";
    Unbinder unbinder;
    Context context;
    @BindView(R.id.nei_press)
    RelativeLayout neiPress;
    @BindView(R.id.wai_press)
    RelativeLayout waiPress;
    @BindView(R.id.pro_gress)
    ProgressBar proGress;

    public DialogLoading(@NonNull Context context) {
        super(context);
        this.context = context;
    }

    public DialogLoading(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        this.context = context;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_progress);
        ButterKnife.bind(this);
    }


    /**
     * 保证同一按钮在1秒内只会响应一次点击事件
     */
    public abstract class OnSingleClickListener implements View.OnClickListener {
        //两次点击按钮之间的间隔，目前为1000ms
        private static final int MIN_CLICK_DELAY_TIME = 1500;
        private long lastClickTime;

        public abstract void onSingleClick(View view);

        @Override
        public void onClick(View view) {
            long curClickTime = System.currentTimeMillis();
            if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
                lastClickTime = curClickTime;
                onSingleClick(view);
            }
        }
    }
}
